package com.it.common.utils

import android.content.Context


object MapUtils {
    fun isAvilible(context: Context, packageName: String): Boolean {
        val packageManager = context.packageManager
        // 获取所有已安装程序的包信息
        val packageInfos = packageManager.getInstalledPackages(0)

        // 用于存储所有已安装程序的包名
        val packageNames = mutableListOf<String>()
        // 从pinfo中将包名字逐一取出，压入pName list中
        if (packageInfos != null) {
            for (i in packageInfos.indices) {
                val packName: String = packageInfos[i].packageName
                packageNames.add(packName)
            }
        }
        // 判断packageNames中是否有目标程序的包名，有TRUE，没有FALSE
        return packageNames.contains(packageName)
    }

}